//域名关键词爬取
<template>
  <el-container>
    <el-header>
      <el-row :gutter="20" style="width: 100%;text-align: left;">
        <el-col :span="14" style="margin-left: 10px;margin-top: 10px;">
          <div class="grid-content ep-bg-purple" />爬虫任务列表
        </el-col>
        <el-col :span="6" style=";float: right;">
          <div class="grid-content ep-bg-purple" /><el-button type="primary" @click="createSplider()">新建爬虫任务</el-button>
        </el-col>
      </el-row>
    </el-header>
    <el-main>
      <Diag v-if="showDialog" ref="Diag" :dialog-title="dialogTitle" :item-info="tableItem" @closeDialog="closeDialog">
      </Diag>

      <div v-for="(item, index) in items" style="margin-top: 20px; height: 20%;" :key="index">
        <Listvue :item="item" :options="options" :index="index" @deletS="taskDelete" :submitUrl="submitUrl"></Listvue>
      </div>
    </el-main>

  </el-container>
</template>



<script>
import Listvue from '../../components/List.vue';
import Diag from '../../components/Diag.vue';


export default {

  data() {
    return {
      userID:1,
      tableLoading: false,
      showDialog: false,
      dialogTitle: "新增爬虫任务",
      tableData: [],
      submitUrl:{
        pauseUrl:'/api/domainCrawling/pauseTask',  //暂停提交的url
        deleteUrl:'/api/domainCrawling/stopTask',
        logUrl:'/api/domainCrawling/logging'
      },
      tableItem: {
        commitUrl: '/api/domainCrawling/startTask', //提交给后端的路径 和参数
        userID: '1',
        crawlerType:'domain'  //采集类型
      },
      items: [],
      options: {
        optionsRenew: [
          {
            value: '全量',
            label: '全量模式',
          },
          {
            value: '增量',
            label: '增量模式',
          },

        ],
        optionsPriority: [{
          value: '低',
          label: '低',
        },
        {
          value: '中',
          label: '中',
        },
        {
          value: '高',
          label: '高',
        }]
      }
      ,
      style1: {
        color: "green",
      },
      style2: {
        color: "red"
      }
    }
  },
  components: {
    Listvue,
    Diag
  },
  beforeMount() {
   
    this.get('/api/domainCrawling/getTasks')

  },
  methods: {
    createSplider() {
      this.dialogTitle = "新增爬虫任务";
      this.showDialog = true;
      this.$nextTick(() => {
        this.$refs["Diag"].showDialog = true;
      });
      
    },
    checkLog() {
      console.log("查看更新日志")
    },
    taskDelete() {  //通过操作下表操作数组不能做到响应式 那么只能通过后端请求数据刷新页面 在下面用axios再调用一次接口即可
     // this.items.append()
      this.get('/api/domainCrawling/getTasks')
    },
    async get(url) {  //async  await  是解决异步的一种方案，必须要加，但是原生封装就不用
      this.$axios.get(url, {
            params: {
                userID: 1
            }
        }).then((res) => {
            console.log(res.data);
            this.items=res.data
        })

    },
    async post(url) {
      this.$axios.post(url, {
            id: 1
        }).then((res) => {
            console.log(res.data);
        })

    }

  }
}
</script>

<style>
.card-header {
  width: 100%;
  height: 100px;
  font-size: 15px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
}

.m-2 {
  width: 60%;
}

.a {
  float: left;
  color: goldenrod;
}

.b {
  float: left;
  color: red;
}
</style>
